/* eslint-disable no-dupe-class-members */
'use strict';

const BaseService = require('./base');

class ThemeDislike extends BaseService {
  async dislike(params) {
    return this.run(async () => {
      const { ctx } = this;
      const result = await ctx.model.ThemeDislike.create(params);
      return result;
    });
  }
  async cancleDislike(id) {
    return this.run(async () => {
      const { ctx } = this;
      const deleteValue = await ctx.model.ThemeDislike.findOne({
        where: {
          id,
        },
      });
      !deleteValue && ctx.helper.commonErr('未查询到数据', {});
      const result = await ctx.model.ThemeDislike.destroy({
        where: {
          id,
        },
      });
      return result;
    });
  }
}

module.exports = ThemeDislike;
